import request from '@/config/axios'

/** 绘本集信息 */
export interface Shelf {
  id: number // 绘本集ID
  title?: string // 绘本集名称
  catalogueId: number // 分类ID
  cover?: string; // 封面图片
  author?: string // 封面颜色
}

// 绘本集 API
export const ShelfApi = {
  // 查询绘本集分页
  getShelfPage: async (params: any) => {
    return await request.get({ url: `/book/shelf/page`, params })
  },

  // 查询绘本集详情
  getShelf: async (id: number) => {
    return await request.get({ url: `/book/shelf/get?id=` + id })
  },

  // 新增绘本集
  createShelf: async (data: Shelf) => {
    return await request.post({ url: `/book/shelf/create`, data })
  },

  // 修改绘本集
  updateShelf: async (data: Shelf) => {
    return await request.put({ url: `/book/shelf/update`, data })
  },

  // 删除绘本集
  deleteShelf: async (id: number) => {
    return await request.delete({ url: `/book/shelf/delete?id=` + id })
  },

  /** 批量删除绘本集 */
  deleteShelfList: async (ids: number[]) => {
    return await request.delete({ url: `/book/shelf/delete-list?ids=${ids.join(',')}` })
  },

  // 导出绘本集 Excel
  exportShelf: async (params) => {
    return await request.download({ url: `/book/shelf/export-excel`, params })
  }
}
